export const widgetDefaultProps = {
    name: 'div',
    attributes: null,
    disabled: null,
    event: null,
    style: {},
};

export const genProps = (defaultProps, options) => {
    let props = $.extend({}, defaultProps);
    if (options) {
        for (let field in defaultProps) {
            if (typeof options[field] !== 'undefined') {
                props[field] = options[field];
            }
            let propsFn = options[`${field}Fn`];
            if (typeof propsFn === 'function') {
                props[field] = propsFn(options);
            }
        }
    }
    for (let field in defaultProps) {
        if (props[field] === null) {
            delete props[field];
        }
    }
    return props;
};

export const ElForm = {
    rules: null,
    inline: false,
    labelPosition: 'right',
    labelWidth: null,
    labelSuffix: null,
    hideRequiredAsterisk: false,
    showMessage: true,
    inlineMessage: false,
    statusIcon: false,
    validateOnRuleChange: true,
    size: null,
    disabled: false,
};

export const ElFormItem = {
    prop: null,
    label: null,
    labelWidth: null,
    required: null,
    rules: null,
    error: null,
    showMessage: null,
    inlineMessage: null,
    size: null,
};

export const ElRadio = {
    label: null,
    disabled: false,
    border: false,
    size: null,
    name: null,
    listenerEvent: {
        input: null,
    },
};

export const ElRadioGroup = {
    size: null,
    disabled: false,
    textColor: '#FFFFFF',
    fill: '#409EFF',
    listenerEvent: {
        input: null,
    },
};

export const ElRadioButton = {
    label: null,
    disabled: false,
    name: null,
};

export const ElCheckbox = {
    label: null,
    trueLabel: null,
    falseLabel: null,
    disabled: false,
    border: false,
    size: null,
    name: null,
    checked: false,
    indeterminate: false,
    listenerEvent: {
        change: null,
    },
};

export const ElCheckboxGroup = {
    size: null,
    disabled: false,
    min: null,
    max: null,
    textColor: '#FFFFFF',
    fill: '#409EFF',
    listenerEvent: {
        change: null,
    },
};

export const ElCheckboxButton = {
    label: null,
    trueLabel: null,
    falseLabel: null,
    disabled: false,
    name: null,
    checked: false,
};

export const ElInput = {
    type: 'text',
    maxlength: null,
    minlength: null,
    showWordLimit: false,
    placeholder: null,
    clearable: true,
    showPassword: false,
    disabled: false,
    size: null,
    suffixIcon: null,
    prefixIcon: null,
    rows: 2,
    autosize: false,
    autocomplete: 'off',
    autoComplete: 'off',
    name: null,
    readonly: false,
    max: null,
    min: null,
    step: null,
    resize: null,
    autofocus: false,
    form: null,
    label: null,
    tabindex: null,
    validateEvent: true,
    listenerEvent: {
        blur: null,
        focus: null,
        change: null,
        input: null,
        clear: null,
    },
    slots: {
        prefix: null,
        suffix: null,
        prepend: null,
        append: null,
    },
};

export const ElInputNumber = {
    max: null,
    min: null,
    step: null,
    stepStrictly: false,
    precision: null,
    size: null,
    disabled: false,
    controls: true,
    controlsPosition: null,
    name: null,
    label: null,
    placeholder: null,
    listenerEvent: {
        change: null,
        blur: null,
        focus: null,
    },
};

export const ElSelect = {
    multiple: false,
    disabled: false,
    valueKey: 'value',
    size: null,
    clearable: false,
    collapseTags: false,
    multipleLimit: 0,
    name: null,
    autocomplete: 'off',
    autoComplete: 'off',
    placeholder: '请选择',
    filterable: false,
    allowCreate: false,
    filterMethod: null,
    remote: false,
    remoteMethod: null,
    loading: false,
    loadingText: '加载中',
    noMatchText: '无匹配数据',
    noDataText: '无数据',
    popperClass: null,
    reserveKeyword: false,
    defaultFirstOption: false,
    popperAppendToBody: true,
    automaticDropdown: false,
    listenerEvent: {
        change: null,
        visibleChange: null,
        removeTag: null,
        clear: null,
        blur: null,
        focus: null,
    },
    slots: {
        prefix: null,
        empty: null,
    },
};

export const ElOptionGroup = {
    label: null,
    disabled: false,
};

export const ElOption = {
    value: null,
    label: null,
    disabled: false,
};

export const ElSwitch = {
    disabled: false,
    width: 40,
    activeIconClass: null,
    inactiveIconClass: null,
    activeText: null,
    inactiveText: null,
    activeValue: true,
    inactiveValue: false,
    activeColor: '#409EFF',
    inactiveColor: '#C0CCDA',
    name: null,
    validateEvent: true,
    listenerEvent: {
        change: null,
    },
};

export const ElSlider = {
    min: 0,
    max: 100,
    disabled: false,
    step: 1,
    showInput: false,
    showInputControls: true,
    inputSize: 'small',
    showStops: false,
    showTooltip: true,
    formatTooltip: null,
    range: false,
    vertical: false,
    height: null,
    label: null,
    debounce: 300,
    tooltipClass: null,
    marks: null,
    listenerEvent: {
        change: null,
    },
};

export const ElTimePicker = {
    readonly: false,
    disabled: false,
    editable: false,
    clearable: true,
    size: null,
    placeholder: null,
    startPlaceholder: null,
    endPlaceholder: null,
    isRange: false,
    arrowControl: false,
    align: 'left',
    popperClass: null,
    popperOptions: {},
    rangeSeparator: '-',
    valueFormat: null,
    defaultValue: null,
    name: null,
    prefixIcon: 'el-icon-time',
    clearIcon: 'el-icon-circle-close',
    listenerEvent: {
        change: null,
        blur: null,
        focus: null,
    },
};

export const ElDatePicker = {
    readonly: false,
    disabled: false,
    editable: true,
    clearable: true,
    size: null,
    placeholder: null,
    startPlaceholder: null,
    endPlaceholder: null,
    type: 'date',
    format: 'yyyy-MM-dd',
    align: 'left',
    popperClass: null,
    pickerOptions: {},
    rangeSeparator: '-',
    defaultValue: null,
    defaultTime: null,
    valueFormat: null,
    name: null,
    unlinkPanels: false,
    prefixIcon: 'el-icon-date',
    clearIcon: 'el-icon-circle-close',
    validateEvent: true,
    appendToBody: true,
    listenerEvent: {
        change: null,
        blur: null,
        focus: null,
    },
};

export const ElDateTimePicker = {
    readonly: false,
    disabled: false,
    editable: true,
    clearable: true,
    size: null,
    placeholder: null,
    startPlaceholder: null,
    endPlaceholder: null,
    timeArrowControl: false,
    type: 'date',
    format: 'yyyy-MM-dd HH:mm:ss',
    align: 'left',
    popperClass: null,
    pickerOptions: {},
    rangeSeparator: '-',
    defaultValue: null,
    defaultTime: null,
    valueFormat: null,
    name: null,
    unlinkPanels: false,
    prefixIcon: 'el-icon-date',
    clearIcon: 'el-icon-circle-close',
    listenerEvent: {
        change: null,
        blur: null,
        focus: null,
    },
    slots: {
        rangeSeparator: null,
    },
};

export const ElUpload = {
    action: null,
    headers: null,
    multiple: null,
    data: null,
    name: 'file',
    withCredentials: false,
    showFileList: true,
    drag: false,
    accept: null,
    onPreview: () => {
    },
    onRemove: () => {
    },
    onSuccess: () => {
    },
    onError: () => {
    },
    onProgress: () => {
    },
    onChange: () => {
    },
    beforeUpload: () => {
    },
    beforeRemove: () => {
    },
    listType: 'text',
    autoUpload: true,
    fileList: [],
    disabled: false,
    limit: null,
    onExceed: null,
    slots: {
        trigger: null,
        tip: null,
    },
};

export const ElRate = {
    max: 5,
    disabled: false,
    allowHalf: false,
    lowThreshold: 2,
    highThreshold: 2,
    colors: ['#F7BA2A', '#F7BA2A', '#F7BA2A'],
    voidColor: '#C6D1DE',
    disabledVoidColor: '#EFF2F7',
    iconClasses: ['el-icon-star-on', 'el-icon-star-on', 'el-icon-star-on'],
    voidIconClass: 'el-icon-star-off',
    disabledVoidIconClass: 'el-icon-star-on',
    showText: false,
    showScore: false,
    textColor: '#1F2D3D',
    texts: ['极差', '失望', '一般', '满意', '惊喜'],
    scoreTemplate: '{value}',
    listenerEvent: {
        change: null,
    },
};

export const ElColorPicker = {
    disabled: false,
    size: null,
    showAlpha: false,
    colorFormat: 'hex',
    popperClass: null,
    predefine: null,
    listenerEvent: {
        change: null,
        activeChange: null,
    },
};

export const ElTransfer = {
    data: null,
    filterable: false,
    filterPlaceholder: '请输入搜索内容',
    filterMethod: null,
    targetOrder: 'original',
    titles: ['列表 1', '列表 2'],
    buttonTexts: [],
    renderContent: null,
    format: {
        noChecked: '${checked}/${total}',
        hasChecked: '${checked}/${total}'
    },
    props: null,
    leftDefaultChecked: [],
    rightDefaultChecked: [],
    listenerEvent: {
        change: null,
        leftCheckChange: null,
        rightCheckChange: null,
    },
    slots: {
        leftFooter: null,
        rightFooter: null,
    },
};

export default {
    genProps,
    ElForm,
    ElFormItem,
    ElRadio,
    ElRadioGroup,
    ElRadioButton,
    ElCheckbox,
    ElCheckboxGroup,
    ElCheckboxButton,
    ElInput,
    ElInputNumber,
    ElSelect,
    ElOptionGroup,
    ElOption,
    ElSwitch,
    ElSlider,
    ElTimePicker,
    ElDatePicker,
    ElDateTimePicker,
    ElUpload,
    ElRate,
    ElColorPicker,
    ElTransfer,
};
